package com.sunda.spmsweb.wmscontroller;


import com.alibaba.fastjson.JSONObject;
import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmswms.service.IWhsOperateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 库存操作日志表 前端控制器
 * </p>
 *
 * @author Wayne
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/whsOperateLog")
@Api(tags = "仓库/储位库存操作日志", description = "仓库/储位库存操作日志")
public class WhsOperateLogController {

    @Autowired
    IWhsOperateLogService iWhsOperateLogService;

    @RequestMapping("/getWhsOperateLog")
    @ApiOperation(value = "获取储位操作日志信息", notes = "获取储位操作日志信息，示例储位编码：b95946ac1dab42b79ade3438acb0b538", httpMethod = "GET")
    public ResponseResult getWhsOperateLog(String uuid) {

        try {
            return ResponseResult.success().add("whsOperateLogList", iWhsOperateLogService.getWhsOperateLog(uuid));
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseResult.error("获取储位操作日志信息出错");
        }
    }

    @PostMapping("/getWhsDeskAccount")
    @ApiOperation(value = "根据条件查询库存台账——全部数据", notes = "根据条件查询库存台账" +
            "{\n" +
            "    \"werks\": \"CN01\",\n" +
            "    \"whsLocationCode\": \"1061\",\n" +
            "    \"documentType\": \"1\", //1自管仓仓库库存日志；2自管仓储位库存日志；3海外仓仓库库存日志；4海外仓储位库存日志；\n" +
            "    \"storageNo\": \"A010101\",\n" +
            "    \"materialNo\": \"2019192\",\n" +
            "    \"boxNote\": \"BJ-BOXNOMBER\",\n" +
            "    \"logCategory\": \"X\", // X-备件 M-贸易\n" +
            "    \"operationType\": \"1\", //1入库(加仓库库存)；2上架(加储位库存)；3下架(减储位库存)；4出库(减仓库库存)；\n" +
            "    \"createTime\": [\n" +
            "        \"2021-04-01\",\n" +
            "        \"2021-05-01\"\n" +
            "    ],\n" +
            "    \"userId\": \"999904\",\n" +
            "}")
    public ResponseResult getWhsDeskAccount(@RequestBody JSONObject filterCriteria) {
        return iWhsOperateLogService.getWhsDeskAccount(filterCriteria);
    }

    @PostMapping("/getWhsDeskAccountPage")
    @ApiOperation(value = "根据条件查询库存台账——分页数据", notes = "根据条件查询库存台账" +
            "{\n" +
            "    \"werks\": \"CN01\",\n" +
            "    \"whsLocationCode\": \"1061\",\n" +
            "    \"documentType\": \"1\", //1自管仓仓库库存日志；2自管仓储位库存日志；3海外仓仓库库存日志；4海外仓储位库存日志；\n" +
            "    \"storageNo\": \"A010101\",\n" +
            "    \"materialNo\": \"2019192\",\n" +
            "    \"boxNote\": \"BJ-BOXNOMBER\",\n" +
            "    \"logCategory\": \"X\", // X-备件 M-贸易\n" +
            "    \"operationType\": \"1\", //1入库(加仓库库存)；2上架(加储位库存)；3下架(减储位库存)；4出库(减仓库库存)；\n" +
            "    \"createTime\": [\n" +
            "        \"2021-04-01\",\n" +
            "        \"2021-05-01\"\n" +
            "    ],\n" +
            "    \"userId\": \"999904\",\n" +
            "    \"pageNo\": 1,\n" +
            "    \"pageSize\": 20\n" +
            "}")
    public ResponseResult getWhsDeskAccountPage(@RequestBody JSONObject filterCriteria) {
        return iWhsOperateLogService.getWhsDeskAccountPage(filterCriteria);
    }

}
